package dnuifood_cjy.dnuifood_16110100529.Fragment;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.widget.Toast;

import java.util.List;

import dnuifood_cjy.dnuifood_16110100529.Adapter.CollectAdapter;

import dnuifood_cjy.dnuifood_16110100529.R;
;
import dnuifood_cjy.dnuifood_16110100529.bean.GetCollected;

import dnuifood_cjy.dnuifood_16110100529.listener.OnRetrofitListener;

import dnuifood_cjy.dnuifood_16110100529.model.UserModel;




    public class CollectShopFragment extends BaseFragment implements OnRetrofitListener<List<GetCollected>> {
        private RecyclerView collect_rv;
        private CollectAdapter adapter;
        private UserModel userModel;

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

            //  return inflater.inflate(R.layout.collectshopfragment, container, false);
            setLayout_file(R.layout.fragment_collect_shop);
            return super.onCreateView(inflater, container, savedInstanceState);
        }

        @Override
        void initViews() {
            collect_rv = (RecyclerView)view.findViewById(R.id.shop_collected_list);
            collect_rv.setLayoutManager(new LinearLayoutManager(getActivity()));
            collect_rv.setHasFixedSize(true);
        }

        @Override
        void initEvents() {

        }


        @Override

        void initData() {
            userModel=new UserModel();
            userModel.getAllUserCollection(getUser_id(),"0",this);

        }


        @Override
        public void onSuccess(List<GetCollected> object, int flag) {
            adapter=new CollectAdapter(context, object,R.layout.shop_item4);
            collect_rv.setAdapter(adapter);
        }

        @Override
        public void onFailure(String msg) {
            Toast.makeText(context, "失败："+msg, Toast.LENGTH_SHORT).show();
        }
    }
